<!DOCTYPE html>
<html>
    <head>
        <title>Test asynchronous setServerCertificate while running garbage collection</title>
        <script src="encrypted-media-utils.js"></script>
        <script src="../../resources/testharness.js"></script>
        <script src="../../resources/testharnessreport.js"></script>
    </head>
    <body>
        <script>
            // Run garbage collection continuously.
            setInterval(asyncGC, 0);

            promise_test(function(test)
            {
                return navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfiguration()).then(function(access) {
                    return access.createMediaKeys();
                }).then(function(mediaKeys) {
                    var cert = new Uint8Array(200);
                    return mediaKeys.setServerCertificate(cert);
                }).then(function(result) {
                    assert_false(result);
                });
            }, 'Test asynchronous setServerCertificate while running garbage collection.');
        </script>
    </body>
</html>
